import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Solution1604 {
    public List<String> alertNames(String[] keyName, String[] keyTime) {
        Map<String,List<String>> map=new HashMap<>();
        for (int i=0;i<keyName.length;i++){
            map.putIfAbsent(keyName[i],new ArrayList<>());
            map.get(keyName[i]).add(keyTime[i]);
        }
        List<String> ans=new ArrayList<>();
        for (Map.Entry<String, List<String>> stringListEntry : map.entrySet()) {
            List<String> temp=stringListEntry.getValue();
            temp.sort(String::compareTo);
            List<Integer> time=new ArrayList<>();
            for (String s : temp) {
                time.add(Integer.parseInt(s.substring(0,2))*60+Integer.parseInt(s.substring(3)));
            }
            for (int j=0;j<temp.size()-2;j++){
                if (time.get(j+2)-time.get(j)<=60 && time.get(j+2)-time.get(j)>0){
                    ans.add(stringListEntry.getKey());
                    break;
                }
            }
        }
        ans.sort(String::compareTo);
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1604().alertNames(new String[]{"daniel","daniel","daniel","luis","luis","luis","luis"},new String[]{"10:00","10:40","11:00","09:00","11:00","13:00","15:00"}));
    }
}
